﻿'
' Boogaloo® - http://www.mindfly.com
' Copyright (c) 2008
' by Mindfly, Inc.
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
' INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
' DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
' SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
' WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
' THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Imports Boogaloo.Base
Imports Boogaloo.Base.DAL

Namespace DAL


    Public MustInherit Class PingServiceDataProvider
        Inherits DataAccess

        Public Sub New()
            With Globals.Settings.Components("Core").Providers("pingservice")
                Me.ConnectionString = .ConnectionString
                Me.EnableCaching = .EnableCaching
                Me.CacheDuration = .CacheDuration
            End With
        End Sub

        ' ping service
        Public MustOverride Function GetPingService(ByVal comment_id As Integer) As PingServiceDetails
        Public MustOverride Function GetPingServices() As List(Of PingServiceDetails)
        Public MustOverride Function InsertPingService(ByVal record As PingServiceDetails) As Integer
        Public MustOverride Function UpdatePingService(ByVal record As PingServiceDetails) As Boolean
        Public MustOverride Function DeletePingService(ByVal comment_id As Integer) As Boolean


#Region "Ping Service"

        Protected Shared Function GetPingServiceDetailsCollectionFromReader(ByVal reader As IDataReader) As List(Of PingServiceDetails)
            Dim recordset As New List(Of PingServiceDetails)
            While reader.read
                recordset.Add(GetPingServiceDetailsFromReader(reader))
            End While
            Return recordset
        End Function

        Protected Shared Function GetPingServiceDetailsFromReader(ByVal reader As IDataReader) As PingServiceDetails
            Return New PingServiceDetails( _
             DataObject.ConvertDBNullToZeroInteger(reader("ping_service_id")), _
             DataObject.ConvertDBNullToString(reader("uri")), _
             CType(reader("created_date"), DateTime), _
             CType(reader("last_modified_date"), DateTime), _
             DataObject.ConvertDBNullToString(reader("last_modified_by")))
        End Function

#End Region



        ''' <summary>
        ''' create instantiation of the Provider of type configured in boogaloo.config
        ''' </summary>
        ''' <remarks>rss - 8/14/2006</remarks>
        Private Shared _Instance As PingServiceDataProvider = Nothing
        Public Shared Function Instance() As PingServiceDataProvider
            If _Instance Is Nothing Then
                _Instance = Activator.CreateInstance(Type.GetType(Globals.Settings.Components("Core").Providers("pingservice").ProviderType))
            End If
            Return _Instance
        End Function

    End Class


End Namespace
